{"ast":null,"code":"import _slicedToArray from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";import React,{useState}from'react';import{Context}from\"../../../index\";import{useForm,Controller,useFormState}from'react-hook-form';import Typography from'@mui/material/Typography';import TextField from'@mui/material/TextField';import{emailValidation,nicknameValidation,passwordValidation,confirmPassword}from'../../validation';import Button from\"../../../components/Button\";import MailOutlineIcon from'@mui/icons-material/MailOutline';import VpnKeyOutlinedIcon from'@mui/icons-material/VpnKeyOutlined';import AlternateEmailOutlinedIcon from'@mui/icons-material/AlternateEmailOutlined';import styles from'../../Form.module.scss';import{jsx as _jsx}from\"react/jsx-runtime\";import{jsxs as _jsxs}from\"react/jsx-runtime\";var RegistrationForm=function RegistrationForm(props){var _React$useContext=React.useContext(Context),store=_React$useContext.store;var _useForm=useForm(),handleSubmit=_useForm.handleSubmit,control=_useForm.control,watch=_useForm.watch;var _useFormState=useFormState({control:control}),errors=_useFormState.errors;var _useState=useState({login:'login'}),_useState2=_slicedToArray(_useState,1),data=_useState2[0];var onSubmit=function onSubmit(data){store.setIsError(false);store.signUp(data);if(props.updateInfo){props.updateInfo(true);}};return/*#__PURE__*/_jsxs(\"div\",{className:styles.authForm,children:[/*#__PURE__*/_jsx(Typography,{variant:\"h4\",component:\"div\",className:styles.authFormTitle,children:\"\\u0417\\u0430\\u0440\\u0435\\u0433\\u0438\\u0441\\u0442\\u0440\\u0438\\u0440\\u0443\\u0439\\u0442\\u0435\\u0441\\u044C\"}),/*#__PURE__*/_jsx(Typography,{variant:\"subtitle1\",gutterBottom:true,component:\"div\",className:styles.authFormSubtitle,children:\"\\u0427\\u0442\\u043E\\u0431\\u044B \\u043F\\u043E\\u043B\\u0443\\u0447\\u0438\\u0442\\u044C \\u0444\\u0443\\u043D\\u043A\\u0446\\u0438\\u043E\\u043D\\u0430\\u043B \\u043F\\u0440\\u0438\\u043B\\u043E\\u0436\\u0435\\u043D\\u0438\\u044F\"}),/*#__PURE__*/_jsxs(\"form\",{className:styles.authForm__form,onSubmit:handleSubmit(onSubmit),children:[/*#__PURE__*/_jsx(Controller,{control:control,name:\"email\",rules:emailValidation,render:function render(_ref){var _errors$email,_errors$email2;var field=_ref.field;return/*#__PURE__*/_jsx(TextField,{label:\"\\u042D\\u043B. \\u0430\\u0434\\u0440\\u0435\\u0441\",InputProps:{endAdornment:/*#__PURE__*/_jsx(MailOutlineIcon,{className:styles.formIcon})},onChange:function onChange(e){return field.onChange(e);},value:field.value||'',fullWidth:true,size:\"small\",margin:\"normal\",type:\"email\",error:!!((_errors$email=errors.email)!==null&&_errors$email!==void 0&&_errors$email.message),helperText:(_errors$email2=errors.email)===null||_errors$email2===void 0?void 0:_errors$email2.message});}}),/*#__PURE__*/_jsx(Controller,{control:control,name:\"nickname\",rules:nicknameValidation,render:function render(_ref2){var _errors$nickname,_errors$nickname2;var field=_ref2.field;return/*#__PURE__*/_jsx(TextField,{label:\"\\u041F\\u0441\\u0435\\u0432\\u0434\\u043E\\u043D\\u0438\\u043C\",InputProps:{endAdornment:/*#__PURE__*/_jsx(AlternateEmailOutlinedIcon,{className:styles.formIcon})},onChange:function onChange(e){return field.onChange(e);},value:field.value||'',fullWidth:true,size:\"small\",margin:\"normal\",type:\"text\",error:!!((_errors$nickname=errors.nickname)!==null&&_errors$nickname!==void 0&&_errors$nickname.message),helperText:(_errors$nickname2=errors.nickname)===null||_errors$nickname2===void 0?void 0:_errors$nickname2.message});}}),/*#__PURE__*/_jsx(Controller,{control:control,name:\"password\",rules:passwordValidation,render:function render(_ref3){var _errors$password,_errors$password2;var field=_ref3.field;return/*#__PURE__*/_jsx(TextField,{label:\"\\u041F\\u0430\\u0440\\u043E\\u043B\\u044C\",InputProps:{endAdornment:/*#__PURE__*/_jsx(VpnKeyOutlinedIcon,{className:styles.formIcon})},onChange:function onChange(e){return field.onChange(e);},value:field.value||'',fullWidth:true,size:\"small\",margin:\"normal\",type:\"password\",helperText:(_errors$password=errors.password)===null||_errors$password===void 0?void 0:_errors$password.message,error:!!((_errors$password2=errors.password)!==null&&_errors$password2!==void 0&&_errors$password2.message)});}}),/*#__PURE__*/_jsx(Controller,{control:control,name:\"confirmPassword\",rules:confirmPassword(watch('password'),watch('confirmPassword')),render:function render(_ref4){var _errors$confirmPasswo,_errors$confirmPasswo2;var field=_ref4.field;return/*#__PURE__*/_jsx(TextField,{label:\"\\u041F\\u043E\\u0432\\u0442\\u043E\\u0440\\u0438\\u0442\\u0435 \\u043F\\u0430\\u0440\\u043E\\u043B\\u044C\",InputProps:{endAdornment:/*#__PURE__*/_jsx(VpnKeyOutlinedIcon,{className:styles.formIcon})},onChange:function onChange(e){return field.onChange(e);},value:field.value||'',fullWidth:true,size:\"small\",margin:\"normal\",type:\"password\",helperText:(_errors$confirmPasswo=errors.confirmPassword)===null||_errors$confirmPasswo===void 0?void 0:_errors$confirmPasswo.message,error:!!((_errors$confirmPasswo2=errors.confirmPassword)!==null&&_errors$confirmPasswo2!==void 0&&_errors$confirmPasswo2.message)});}}),/*#__PURE__*/_jsx(Button,{text:'Регистрация'})]}),/*#__PURE__*/_jsx(\"div\",{className:styles.authForm__footer,children:/*#__PURE__*/_jsx(Typography,{variant:\"subtitle1\",component:\"span\",className:styles.link,onClick:function onClick(){store.setIsError(false);if(props.updateInfo){props.updateInfo(false);}props.updateData(data.login);},children:\"\\u0412\\u043E\\u0439\\u0442\\u0438\"})})]});};export default RegistrationForm;","map":{"version":3,"names":["React","useState","Context","useForm","Controller","useFormState","Typography","TextField","emailValidation","nicknameValidation","passwordValidation","confirmPassword","Button","MailOutlineIcon","VpnKeyOutlinedIcon","AlternateEmailOutlinedIcon","styles","RegistrationForm","props","useContext","store","handleSubmit","control","watch","errors","login","data","onSubmit","setIsError","signUp","updateInfo","authForm","authFormTitle","authFormSubtitle","authForm__form","field","endAdornment","formIcon","e","onChange","value","email","message","nickname","password","authForm__footer","link","updateData"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/modules/RegistrationForm/components/RegistrationForm.tsx"],"sourcesContent":["import React, {useState} from 'react';\nimport {Context} from \"../../../index\";\nimport {useForm, Controller, SubmitHandler, useFormState} from 'react-hook-form';\nimport SignUpRequest from \"../../../models/request/SignUpRequest\";\nimport Typography from '@mui/material/Typography';\nimport TextField from '@mui/material/TextField';\nimport {emailValidation, nicknameValidation, passwordValidation, confirmPassword} from '../../validation';\nimport {AuthProps} from \"../../../models/props/AuthProps\";\nimport Button from \"../../../components/Button\";\nimport MailOutlineIcon from '@mui/icons-material/MailOutline';\nimport VpnKeyOutlinedIcon from '@mui/icons-material/VpnKeyOutlined';\nimport AlternateEmailOutlinedIcon from '@mui/icons-material/AlternateEmailOutlined';\nimport styles from '../../Form.module.scss';\n\nconst RegistrationForm: React.FC<AuthProps> = (props) => {\n    const {store} = React.useContext(Context);\n    const {handleSubmit, control, watch} = useForm<SignUpRequest>();\n    const {errors} = useFormState({control});\n    const [data] = useState({\n            login: 'login'\n        }\n    );\n\n    const onSubmit: SubmitHandler<SignUpRequest> = (data) => {\n        store.setIsError(false);\n        store.signUp(data);\n        if (props.updateInfo) {\n            props.updateInfo(true);\n        }\n    };\n\n    return (\n        <div className={styles.authForm}>\n            <Typography variant=\"h4\" component=\"div\" className={styles.authFormTitle}>\n                Зарегистрируйтесь\n            </Typography>\n            <Typography variant=\"subtitle1\" gutterBottom component=\"div\" className={styles.authFormSubtitle}>\n                Чтобы получить функционал приложения\n            </Typography>\n\n            <form className={styles.authForm__form} onSubmit={handleSubmit(onSubmit)}>\n                <Controller\n                    control={control}\n                    name=\"email\"\n                    rules={emailValidation}\n                    render={({ field }) => (\n                        <TextField\n                            label=\"Эл. адрес\"\n                            InputProps={{\n                                endAdornment: (\n                                    <MailOutlineIcon className={styles.formIcon}/>\n                                ),\n                            }}\n                            onChange={(e) => field.onChange(e)}\n                            value={field.value || ''}\n                            fullWidth={ true }\n                            size=\"small\"\n                            margin=\"normal\"\n                            type=\"email\"\n                            error={!!errors.email?.message}\n                            helperText={errors.email?.message}\n                        />\n                    )}\n                />\n                <Controller\n                    control={control}\n                    name=\"nickname\"\n                    rules={nicknameValidation}\n                    render={({ field }) => (\n                        <TextField\n                            label=\"Псевдоним\"\n                            InputProps={{\n                                endAdornment: (\n                                    <AlternateEmailOutlinedIcon className={styles.formIcon}/>\n                                ),\n                            }}\n                            onChange={(e) => field.onChange(e)}\n                            value={field.value || ''}\n                            fullWidth={ true }\n                            size=\"small\"\n                            margin=\"normal\"\n                            type=\"text\"\n                            error={!!errors.nickname?.message}\n                            helperText={errors.nickname?.message}\n                        />\n                    )}\n                />\n                <Controller\n                    control={control}\n                    name=\"password\"\n                    rules={passwordValidation}\n                    render={({ field }) => (\n                        <TextField\n                            label=\"Пароль\"\n                            InputProps={{\n                                endAdornment: (\n                                    <VpnKeyOutlinedIcon className={styles.formIcon}/>\n                                ),\n                            }}\n                            onChange={(e) => field.onChange(e)}\n                            value={field.value || ''}\n                            fullWidth={ true }\n                            size=\"small\"\n                            margin=\"normal\"\n                            type=\"password\"\n                            helperText={errors.password?.message}\n                            error={!!errors.password?.message}\n                        />\n                    )}\n                />\n                <Controller\n                    control={control}\n                    name=\"confirmPassword\"\n                    rules={confirmPassword(watch('password'), watch('confirmPassword'))}\n                    render={({ field }) => (\n                        <TextField\n                            label=\"Повторите пароль\"\n                            InputProps={{\n                                endAdornment: (\n                                    <VpnKeyOutlinedIcon className={styles.formIcon}/>\n                                ),\n                            }}\n                            onChange={(e) => field.onChange(e)}\n                            value={field.value || ''}\n                            fullWidth={ true }\n                            size=\"small\"\n                            margin=\"normal\"\n                            type=\"password\"\n                            helperText={errors.confirmPassword?.message}\n                            error={!!errors.confirmPassword?.message}\n                        />\n                    )}\n                />\n                <Button text={'Регистрация'} />\n            </form>\n\n            <div className={styles.authForm__footer}>\n                <Typography variant=\"subtitle1\" component=\"span\" className={styles.link}\n                            onClick = {() => {\n                                store.setIsError(false);\n                                if (props.updateInfo) {\n                                    props.updateInfo(false);\n                                }\n                                props.updateData(data.login);\n                            }}>\n                    Войти\n                </Typography>\n            </div>\n        </div>\n    );\n}\n\nexport default RegistrationForm;"],"mappings":"8IAAA,MAAOA,MAAK,EAAGC,QAAQ,KAAO,OAAO,CACrC,OAAQC,OAAO,KAAO,gBAAgB,CACtC,OAAQC,OAAO,CAAEC,UAAU,CAAiBC,YAAY,KAAO,iBAAiB,CAEhF,MAAOC,WAAU,KAAM,0BAA0B,CACjD,MAAOC,UAAS,KAAM,yBAAyB,CAC/C,OAAQC,eAAe,CAAEC,kBAAkB,CAAEC,kBAAkB,CAAEC,eAAe,KAAO,kBAAkB,CAEzG,MAAOC,OAAM,KAAM,4BAA4B,CAC/C,MAAOC,gBAAe,KAAM,iCAAiC,CAC7D,MAAOC,mBAAkB,KAAM,oCAAoC,CACnE,MAAOC,2BAA0B,KAAM,4CAA4C,CACnF,MAAOC,OAAM,KAAM,wBAAwB,CAAC,wFAE5C,GAAMC,iBAAqC,CAAG,QAAxCA,iBAAqC,CAAIC,KAAK,CAAK,CACrD,sBAAgBlB,KAAK,CAACmB,UAAU,CAACjB,OAAO,CAAC,CAAlCkB,KAAK,mBAALA,KAAK,CACZ,aAAuCjB,OAAO,EAAiB,CAAxDkB,YAAY,UAAZA,YAAY,CAAEC,OAAO,UAAPA,OAAO,CAAEC,KAAK,UAALA,KAAK,CACnC,kBAAiBlB,YAAY,CAAC,CAACiB,OAAO,CAAPA,OAAO,CAAC,CAAC,CAAjCE,MAAM,eAANA,MAAM,CACb,cAAevB,QAAQ,CAAC,CAChBwB,KAAK,CAAE,OACX,CAAC,CACJ,wCAHMC,IAAI,eAKX,GAAMC,SAAsC,CAAG,QAAzCA,SAAsC,CAAID,IAAI,CAAK,CACrDN,KAAK,CAACQ,UAAU,CAAC,KAAK,CAAC,CACvBR,KAAK,CAACS,MAAM,CAACH,IAAI,CAAC,CAClB,GAAIR,KAAK,CAACY,UAAU,CAAE,CAClBZ,KAAK,CAACY,UAAU,CAAC,IAAI,CAAC,CAC1B,CACJ,CAAC,CAED,m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